package org.ddr.member.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.ddr.member.dao.MemberDAO;
import org.ddr.member.vo.MemberVO;
import org.ddr.servlet.URIServlet;

/**
 * Servlet implementation class MemberController
 */
@WebServlet("/member/*")
public class MemberController extends URIServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see URIServlet#URIServlet()
	 */
	public MemberController() {
		super();
		// TODO Auto-generated constructor stub
	}

	public void login(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		log.info("login..............");
		
			request.getRequestDispatcher(
					VIEW_PREFIX + request.getRequestURI() + VIEW_APPENDIX)
					.forward(request, response);
		
			List<MemberVO> list = new ArrayList<MemberVO>();
			HttpSession session = request.getSession();
			session.setAttribute("Login", request.getParameter("id"));
			list = MemberDAO.instance.getUser(request.getParameter("id"),
					request.getParameter("pw"));
			session.setAttribute("Login", list.get(0).getUserid());
			response.sendRedirect("http://www.d2r.org/bbs/list");
		
	}

}
